<%-
  channel_kinds = Channel::Kinds.dup
  channel_kinds.map!{|x| ["#{x} channel", x]}
  channel_kinds = [['Create new...', '']] + channel_kinds
-%>
<%= select_tag('new_channel', options_for_select(channel_kinds), :onchange => 'create_channel(this)') -%>

<br/>

<% if @channels.present? %>
  <br/>
  <table class="table">
    <tr>
      <th>Name</th>
      <th>Application</th>
      <th>Kind</th>
      <th></th>
    </tr>
    <% @channels.each do |channel| %>
      <tr>
        <td><%= channel.name %></td>
        <td><%= channel.application.try(:name) %></td>
        <td><%= channel.kind %></td>
        <td>
          <%= link_to 'view', channel %>
          <%= link_to 'queued calls', channel_queued_calls_path(channel), :class => 'fancybox' %>
          <%= link_to 'call...', call_channel_path(channel), :class => 'fancybox' %>
          <%= link_to 'edit', edit_channel_path(channel) %>
          <%= link_to 'delete', channel, :confirm => "Are you sure you want to delete the channel #{channel.name}?", :method => :delete %>
        </td>
      </tr>
    <% end %>
  </table>

  <script type="text/javascript">
    $(function() {
      $('.fancybox').fancybox({autoDimensions: false, width: 600, height: 400});
    });
  </script>
<% end %>

<br />
